package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.zr.gdms.model.Student;
import com.zr.gdms.model.User;
import com.zr.gdms.service.StudentServiceSCM;
import com.zr.gdms.serviceimpl.StudentServiceImplSCM;

/**
 * @author  shichongming
 * @E-mail: 
 * @date 创建时间：2017年5月25日 上午9:34:59 
 * @version 1.0 
 * @parameter  
 * @since  
 * @return  
 */




//通过用户的uid获取到学生信息
public class StudentInfoControllerSCM  extends HttpServlet {

	  StudentServiceSCM stu=new StudentServiceImplSCM();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
	            doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {		
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		HttpSession session = req.getSession();
		User u=(User) session.getAttribute("user");
		Student st=stu.sfindStudentByUid(u.getUid());		
		session.setAttribute("student", st);
		JSONArray j=JSONArray.fromObject(st);
		PrintWriter pw=resp.getWriter();
		pw.write(j.toString());	
	
		
	}
	
	
}
